﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JotCMS;

namespace JotCMS
{
    /// <summary>
    /// Summary description for ContentAction
    /// </summary>
    public class ContentAction : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string Content_Name = context.Request.Form["Content_Name"].ToString();
            string HTMLContent = context.Request.Form["HTMLContent"].ToString();
            string Action = context.Request.Form["Action"].ToString();

            Jot jot = new Jot();

            switch(Action)
            {
                case "Save":
                    jot.SaveContent(Content_Name, HTMLContent);    
                    break;
                case "Publish":
                    // code to publish from draft
                    break;
                case "ResetItemCache":
                    jot.RemoveCacheItem(Content_Name);
                    break;
                case "ResetAllCache":
                    jot.RemoveAllCacheItems();
                    break;
            }
            
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}